package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.AdminPrizeConfigMapper;
import com.ruoyi.system.domain.AdminPrizeConfig;
import com.ruoyi.system.service.IAdminPrizeConfigService;

/**
 * 开奖设置Service业务层处理
 * 
 * @author ruoyi
 * @date 2020-09-22
 */
@Service
public class AdminPrizeConfigServiceImpl implements IAdminPrizeConfigService
{
    @Autowired
    private AdminPrizeConfigMapper adminPrizeConfigMapper;

    /**
     * 查询开奖设置
     * 
     * @param configId 开奖设置ID
     * @return 开奖设置
     */
    @Override
    public AdminPrizeConfig selectAdminPrizeConfigById(Long configId)
    {
        return adminPrizeConfigMapper.selectAdminPrizeConfigById(configId);
    }

    @Override
    public AdminPrizeConfig selectAdminPrizeConfigByKey(String configKey) {
        return adminPrizeConfigMapper.selectAdminPrizeConfigByKey(configKey);
    }

    /**
     * 查询开奖设置列表
     * 
     * @param adminPrizeConfig 开奖设置
     * @return 开奖设置
     */
    @Override
    public List<AdminPrizeConfig> selectAdminPrizeConfigList(AdminPrizeConfig adminPrizeConfig)
    {
        return adminPrizeConfigMapper.selectAdminPrizeConfigList(adminPrizeConfig);
    }

    /**
     * 新增开奖设置
     * 
     * @param adminPrizeConfig 开奖设置
     * @return 结果
     */
    @Override
    public int insertAdminPrizeConfig(AdminPrizeConfig adminPrizeConfig)
    {
        adminPrizeConfig.setCreateTime(DateUtils.getNowDate());
        return adminPrizeConfigMapper.insertAdminPrizeConfig(adminPrizeConfig);
    }

    /**
     * 修改开奖设置
     * 
     * @param adminPrizeConfig 开奖设置
     * @return 结果
     */
    @Override
    public int updateAdminPrizeConfig(AdminPrizeConfig adminPrizeConfig)
    {
        if (adminPrizeConfig.getConfigKey().equals("state") && adminPrizeConfig.getConfigValue().equals("2")) {
            //关闭开奖时删除预设置开奖时间的数据
        }
        adminPrizeConfig.setUpdateTime(DateUtils.getNowDate());
        return adminPrizeConfigMapper.updateAdminPrizeConfig(adminPrizeConfig);
    }

    /**
     * 批量删除开奖设置
     * 
     * @param configIds 需要删除的开奖设置ID
     * @return 结果
     */
    @Override
    public int deleteAdminPrizeConfigByIds(Long[] configIds)
    {
        return adminPrizeConfigMapper.deleteAdminPrizeConfigByIds(configIds);
    }

    /**
     * 删除开奖设置信息
     * 
     * @param configId 开奖设置ID
     * @return 结果
     */
    @Override
    public int deleteAdminPrizeConfigById(Long configId)
    {
        return adminPrizeConfigMapper.deleteAdminPrizeConfigById(configId);
    }
}
